package io.github.lee.jel.global.di.http.interceptor

import android.os.Build
import io.github.lee.jel.BuildConfig
import okhttp3.Interceptor
import okhttp3.Response


class PublicHeaderInterceptor(private val userId: String) : Interceptor {
    override fun intercept(chain: Interceptor.Chain): Response {
        val client = "Android"
        val device = Build.MANUFACTURER + " " + Build.MODEL
        val deviceId = "$userId $device"
        val version = BuildConfig.VERSION_NAME

        val auth =
            "Emby UserId=\"$userId\", Client=\"$client\", Device=\"$device\", DeviceId=\"$deviceId\", Version=\"$version\""

        return chain.proceed(
            chain.request()
                .newBuilder()
                .addHeader("Authorization", auth)
                .build()
        )
    }

}